import * as path from 'path';
import * as fs from 'fs';
import { parse } from 'yaml';

export const getEnv = () => {
  return process.env.RUNNING_ENV;
};

export const getConfig = (): Record<string, any> => {
  const env = getEnv();
  const ymlpath = path.join(process.cwd(), `./.config/.${env}.yaml`);
  const file = fs.readFileSync(ymlpath, 'utf8');
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
  const config = parse(file);
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
  return config;
};
